﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QuanLyKho.Server
{
    public partial class PhieuNhapThuocChiTiet
    {
        public string TenThuoc 
        {
            get
            {
                if (Dm_Thuoc != null)
                    return Dm_Thuoc.TenThuoc;
                return null;
            }
            set {
                if (!string.IsNullOrEmpty(value))
                {
                    if(Dm_Thuoc == null)
                    {
                        Dm_Thuoc = new Dm_Thuoc();
                    }
                    Dm_Thuoc.TenThuoc = value;
                }
            } 
        }

        public string TenHamLuong
        {
            get
            {
                if (Dm_Thuoc != null && Dm_Thuoc.Dm_HamLuong != null)
                    return Dm_Thuoc.Dm_HamLuong.TenHamLuong;
                return null;
            }
            set { ;}
        }

        public string TenNhaPhanPhoi
        {
            get
            {
                try
                {
                    if (PhieuNhapThuoc != null && PhieuNhapThuoc.Dm_NhaPhanPhoi != null)
                        return PhieuNhapThuoc.Dm_NhaPhanPhoi.TenNhaPhanPhoi;
                    return null;
                }
                catch (Exception)
                {
                    return null;
                }
            }
            set { ;}
        }

        public string TenDonViTinh
        {
            get
            {
                if (Dm_Thuoc != null && Dm_Thuoc.Dm_DonViTinh != null)
                    return Dm_Thuoc.Dm_DonViTinh.TenDonViTinh;
                return null;
            }
            set { ;}
        }

        private byte chietKhau;
        public byte ChietKhau
        {
            get
            {
                if (chietKhau == 0)
                {
                    if (PhieuNhapThuoc != null)
                    {
                        return PhieuNhapThuoc.ChietKhau;
                    }
                    else
                    {
                        return chietKhau;
                    }
                }
                else
                {
                    return chietKhau; 
                }
                return 0;
            }
            set {
                chietKhau = value;
            }
        }
    }
}
